package com.bwie.gddproject.index.precenter;

import android.util.Log;

import com.bwie.gddproject.index.model.IShopCarModel;
import com.bwie.gddproject.index.model.ShopCarModel;
import com.bwie.gddproject.index.model.bean.GoodCarBean;
import com.bwie.gddproject.index.view.fragment.IShopCarFragment;
import com.bwie.gddproject.net.OnNetLitenner;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by peng on 2017/11/16.
 */

public class ShopCarPresenter implements IShopCarPrecenter{

    private final IShopCarModel imainModel;
    private final IShopCarFragment shopCarFragment;

    public ShopCarPresenter(IShopCarFragment shopCarFragment) {
        this.shopCarFragment = shopCarFragment;
        imainModel = new ShopCarModel();
    }

    public void getGoods() {
        imainModel.getGoods(new OnNetLitenner<GoodCarBean>() {
            @Override
            public void success(GoodCarBean goodCarBean) {
                //List<GoosBean.DataBean> groupList, List<List<GoosBean.DataBean.DatasBean>> childList
                List<GoodCarBean.DataBean> dataBean = goodCarBean.getData();
                List<List<GoodCarBean.DataBean.ListBean>> childList = new ArrayList<List<GoodCarBean.DataBean.ListBean>>();
                for (int i = 0; i < dataBean.size(); i++) {
                    List<GoodCarBean.DataBean.ListBean> datas = dataBean.get(i).getList();
                    childList.add(datas);
                }
                Log.e("tag",dataBean.size()+"");

                shopCarFragment.showList(dataBean, childList);
            }

            @Override
            public void fail(String errer){
                Log.e("tag","123");
            }
        });

    }
}
